<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<jsp:useBean id="ss" class="beans.DAOCLass" scope="page"></jsp:useBean>
<title>Insert title here</title>

</head>
<body>
<body onLoad="document.page2form.id.focus();">
	<FORM action="SearchServlet" METHOD="GET" name="page2form">
		<input type="hidden" name="page" value="2">
		<H1>Second page</H1>
		<%
			String searchTerm = (String) request.getSession().getAttribute(
					"searchTerm");
			String searchOption = (String) request.getSession().getAttribute(
					"searchOption");
		%>



		<%
			if(searchTerm != null && !searchTerm.isEmpty()){
			out.write("<table><tr><th>ID</th><th>Description</th></tr>");

			for (String newItem : ss.getData(searchTerm, searchOption)) {

				String temp[] = newItem.split("/");

				out.write("<tr><td>" + temp[1] + "</td><td>" + temp[0]
						+ "</td></tr>");

			}
			out.write("</table>");
			}
			else
			{
				out.write("Your search has returned no results!");
			}
		%>
		</form>
		
		<FORM action="SearchServlet" METHOD="GET" name="page2formsearch">
		<input type="hidden" name="page" value="1">
		
		<p>What would you like to search?</p>
		<input type="text" name="searchTerm"> <select
			name="searchOption">
			<option value="0">Description</option>
			<option value="1">Category</option>
		</select><br> <input type="submit" value="Submit">
	</FORM>
</body>
</html>